import {apiGet,apiPost} from './apiCommon'
export  default{
  state: {
    headerData:null,
    globalLoading:false,
    headerHeight:0,
  },
  mutations: {
    'setHeaderData'(state,data) {
      state.headerData = data;
    },
    'setGlobalLoading'(state,flag){
      state.globalLoading = flag
    },
    'setHeaderHeight'(state,num){
      state.headerHeight = num
    },
  },
  actions: {
    getHeaderData:({commit},option) =>{
      apiPost('/home/homeIndex/index.do',commit,option,function (data) {
        commit('setHeaderData',data);
      });
    }
  },
  getters: {
    headerData:(state, getters) => {
      return state.headerData;
    },
    menuData:(state, getters) =>{
      if (state.headerData){
        return state.headerData.beans[0].nodes;
      }
    },
    globalLoading:(state, getters) =>{
      return state.globalLoading;
    },
    headerHeight:(state, getters) =>{
      return state.headerHeight;
    },
  }
}
